<!--
* @author luguoxiang
* @date 2021-09-07
* 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
-->
<template>
  {{ text }}
</template>

<script lang="ts" setup>
import { computed } from 'vue';
import { LgFormatProps } from '../types';
import { format } from '@/soar';

interface Props extends LgFormatProps {
  /**
   * 格式
   */
  format?:
    | 'bigint'
    | 'number'
    | 'datetime'
    | 'date'
    | 'time'
    | 'CNY'
    | 'USD'
    | 'EUR'
    | 'file'
    | 'percent'
    | string
    | number;
  /**
   * 值
   */
  value?: any | any[];
}
const props = defineProps<Props>();
const text = computed(() => {
  const { value } = props;
  if (value === undefined || value === null) {
    return value;
  }
  return format(value, props.format);
});
</script>
<script lang="ts">
export default {
  name: 'LgFormat',
};
</script>
